package com.ytoglobal.overseas.address.platform.common.exception;

import com.ytoglobal.overseas.address.platform.common.emum.AppStatus;

/**
 * <pre>
 * 名称: AppException
 * 描述: AppException
 * </pre>
 * @author Ryan Chen
 * @since 1.0.0
 */
public class AppException extends RuntimeException {

    private int status;
    private transient Object returnObj;

    /**
     * 构造方法
     * @param appStatus 错误状态枚举
     */
    public AppException(final AppStatus appStatus) {
        super(appStatus.message());
        this.status = appStatus.status();
    }

    /**
     * 构造方法
     * @param status 错误代码
     * @param msg       错误消息
     */
    public AppException(final int status, final String msg) {
        super(msg);
        this.status = status;
    }

    /**
     * 构造方法
     * @param status 错误代码
     * @param msg       错误消息
     * @param returnObj BaseResponse
     */
    public AppException(final int status, final String msg, final Object returnObj) {
        super(msg);
        this.status = status;
        this.returnObj = returnObj;
    }

    /**
     * 构造方法
     * @param status 错误代码
     * @param msg       错误消息
     * @param returnObj BaseResponse
     */
    public AppException(final int status, final String msg, final Object returnObj, final Throwable cause) {
        super(msg, cause);
        this.status = status;
        this.returnObj = returnObj;
    }


    /**
     * 构造方法
     * @param cause     错误栈
     */
    public AppException(final Throwable cause) {
        super(cause);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Object getReturnObj() {
        return returnObj;
    }

    public void setReturnObj(Object returnObj) {
        this.returnObj = returnObj;
    }
}
